<#include "common/common.html"/>
<meta charset="UTF-8">
<table class="easyui-datagrid" id="datagrid" title="黑名单管理"
	url="${base}/userblacklist/listPage" toolbar="#searchtool,#toolbar"
	pagination="true" rownumbers="true" fitColumns="true"
	singleSelect="true"
	data-options="fit:false,border:false,pageSize:20,pageList:[5,10,15,20]">
	<thead>
		<tr>
			<th field="id" width="6%" checkbox="true">编号</th>
			<th field="userId" width="8%">用户ID</th>
			<th field="mobile" width="9%" formatter="formatMobile">手机号</th>
			<th field="ctime" width="10%" formatter="formatCtime">注册时间</th>
			<th field="industry" width="8%" formatter="formatIndustry">所属行业</th>
			<th field="realname" width="8%" formatter="formatRealname">真实姓名</th>
			<th field="expireTime" formatter="formatLongDate" width="20%">过期时间</th>
			<th field="createTime" formatter="formatLongDate" width="20%">创建时间</th>
			<!--   <th field="operate" width="18%" formatter="formatOper">操作</th>    -->
		</tr>
	</thead>
</table>
<div id="toolbar">
	<a href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-add" plain="true" onclick="openNewDlg();">添加</a> <a
		href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-edit" plain="true" onclick="openEditDlg();">修改</a> <a
		href="javascript:void(0)" class="easyui-linkbutton"
		iconCls="icon-remove" plain="true"
		onclick="singleDel('userblacklist/dodelete');">删除</a>
</div>
<div id="blacklist-dlg" class="easyui-dialog"
	style="padding: 10px 20px;"
	data-options="iconCls:'icon-edit',closed:true,modal:true,resizable:true,buttons:'#dlg-buttons'">
	<form id="blacklist-fm" method="post">
		<div class="fitem">
			<label>手机号:</label><input type="hidden" id="id" name="id" /> <input
				type="hidden" id="userId" name="userId" />
					<input name="mobile" id="mobile" onclick="selectUser();"
				readonly="readonly">&nbsp;&nbsp; 
		</div>
		<div class="fitem">
		<label>过期时间:</label> <input
				name="expireTime" id="expireTime" class="easyui-datetimebox"
				data-options="editable:false" style="width: 200px" required="true">
		</div>

	</form>
</div>
<div id="dlg-buttons">
	<a href="javascript:void(0)" id="saveBtn" class="easyui-linkbutton c6"
		iconCls="icon-ok" onclick="mySubmit('blacklist-dlg','blacklist-fm')"
		style="width: 90px">提交</a> <a href="javascript:void(0)"
		class="easyui-linkbutton" iconCls="icon-cancel"
		onclick="$('#blacklist-dlg').dialog('close')" style="width: 90px">取消</a>
</div>
<div id="userDiv" class="easyui-window" style="padding: 10px 20px"
	closed="true" modal="true"></div>
<script>
	function openNewDlg() {
		centerDialog("blacklist-dlg").dialog('open')
				.dialog('setTitle', "添加黑名单");
		$("#blacklist-fm").form('clear');
		url = $("#base").val() + "/userblacklist/doadd";
	}

	function openEditDlg() {
		var rows = $('#datagrid').datagrid('getSelections');
		centerDialog("blacklist-dlg").dialog('open')
				.dialog('setTitle', "修改黑名单");
		$("#blacklist-dlg").form('clear');

		//$("#blacklist-dlg").form('load', rows[0]);

		$("#id").val(rows[0].id);
		$("#userId").val(rows[0].user.uid);
		$("#mobile").val(rows[0].user.umobile);
		console.log(rows[0].expireTime);
		console.log(getFormatDateByLong(rows[0].expireTime));
		$("#expireTime").datetimebox("setValue",
				getFormatDateByLong(rows[0].expireTime));
		url = $("#base").val() + "/userblacklist/doupdate";
	}
	function selectUser() {
		var rect = centerRect(window.parent);
		var win = $('#userDiv').window({
			href : base+'/userblacklist/listNotInBlacklistPage',
			title : '选择用户',
			width : rect.width,
			height : rect.height,
			top : rect.top,
			left : rect.left,
			shadow : true,
			modal : true,
			iconCls : 'icon-add',
			closed : true,
			minimizable : false,
			maximizable : false,
			collapsible : false
		});

		win.window('open');
	}
	function doSelelectUser() {
		var rows = $('#datagrid2').datagrid('getSelections');
		console.log(rows[0].uid);
		$('#userId').val(rows[0].uid);
		$('#mobile').val(rows[0].umobile);
		$('#userDiv').window('close');
	}
	function mySubmit(divId, formId) {
		console.log("Try to submit project");
		submit(divId, formId);
	}
	function formatMobile(val, row, index) {
		var mobile = "";
		if (row.user) {
			mobile = row.user.umobile;
		}
		return mobile;
	}
	function formatRealname(val, row, index) {
		return row.user.realname;
	}
	function formatIndustry(val, row, index) {
		return row.user.industry;
	}
	function formatCtime(val, row, index) {
		return getFormatDateByLong(row.user.ctime, "yyyy-MM-dd hh:mm:ss")
	}
</script>